﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VERKProjectHopur16.Models;
using System.Web.Caching;

namespace VERKProjectHopur16.Helpers
{
    /// <summary>
    /// Class includes two functins which create a collection of objects.
    /// This functions are used for updating cache variable when content is updated.
    /// </summary>
    public class CacheUpdate
    {
        DataRepository m_rep = new DataRepository();

        public IEnumerable<QA> UpdateCacheQA()
        {
            IEnumerable<QA> LatestQA = (from art in m_rep.AllQA()
                                        where art.Active == true
                                        && art.Answered == true
                                        orderby art.InsertDate descending
                                        select art).Take(5);
            return LatestQA;
        }

        public IEnumerable<Eventss> UpdateCacheEvent()
        {
            IEnumerable<Eventss> LatestEvents = (from art in m_rep.GetAllEvent()
                                                where art.Active == true
                                                orderby art.StartDate descending
                                                select art).Take(5);
            return LatestEvents;
        }
    }
}